package com.itheima.threadPool;
import java.util.TreeSet;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Demo {
    public static void main(String[] args) {
        //创建线程池对象
        ExecutorService es = Executors.newCachedThreadPool();
        //submit(Runnable);方法中写的是任务
        es.submit(()->{
            System.out.println(Thread.currentThread().getName()+"在执行了");

        });

        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        es.submit(()->{
            System.out.println(Thread.currentThread().getName()+"在执行了");

        });


        es.shutdown();
    }
}
